package com.lzk.auth.service.impl;

import com.lzk.model.system.SysDevice;
import com.lzk.auth.mapper.DeviceMapper;
import com.lzk.auth.service.DeviceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.lzk.model.system.SysOrder;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lzk
 * @since 2023-12-29
 */
@Service
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, SysDevice> implements DeviceService {
    //统计设备状态
    @Override
    public List<Integer> deviceStatus() {
        List<SysDevice> sysDevices = baseMapper.selectList(null);
        List<Integer> statusCounts = new ArrayList<>(Arrays.asList(0, 0, 0, 0,0));

        for (SysDevice sysDevice : sysDevices) {
            Integer dStatus = sysDevice.getDStatus();

            int count = statusCounts.get(dStatus);
            System.out.println(count);
            statusCounts.set(dStatus, count + 1);
        }
        return statusCounts;
    }
}
